import axios from 'axios'
export default {
  namespaced: true,
  state: {
    token: '',
    userInfo: {}
  },
  mutations: {
    updatetoken (state, token) {
      state.token = token
      // console.log(token)
    },
    updateUserInfo (state, userInfo) {
      state.userInfo = userInfo
      // console.log(state.userInfo)
    }
  },
  actions: {
    async getUserInfo (context) {
      const { data: res } = await axios.get('/my/userinfo'
      //  {
      //   headers: { Authorization: context.state.token }
      // }
      )
      // console.log(res)
      // console.log(context)
      context.commit('updateUserInfo', res.data)
    }
  },
  getters: {

  }
}
